import { createSelector, createSlice, PayloadAction } from "@reduxjs/toolkit"

interface GameReviewState {
	data: any
}

const initialState: GameReviewState = {
	data: undefined
}

const gameReviewSlice = createSlice({
	name: "gameReview",
	initialState,
	reducers: {
		setDataGameReview: (state, action: PayloadAction<any>) => {
			state.data = action.payload
		}
	}
})

export const gameReviewState = (rootState: { gameReview: GameReviewState }): GameReviewState => {
	return rootState.gameReview
}

export const getDataGameReview = createSelector(gameReviewState, (state: GameReviewState) => state.data)

export const { setDataGameReview } = gameReviewSlice.actions

export default gameReviewSlice.reducer
